<?php
defined('_JEXEC') or die;

require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
if ( $detect->isMobile() ) {
    include('edit_mobile.php');
    return;
}

JHtml::_('behavior.keepalive');
$tpath	= JURI::base().'templates/'.JFactory::$application->getTemplate();
extract($this->data->information);//keys 2 variables
$user = JFactory::getUser();
?>
<script type="text/javascript">
function isValidEmail(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);

	return pattern.test(emailAddress);
}

function check()
{
	var temp=0;
	if(jQuery("#fornave").val()==''){
			 jQuery("#fornave").attr('style','border:1px solid red');
			temp=1;
	}
	else
		jQuery("#fornave").attr('style','solid 1px #C5C5C5');


	if(jQuery("#efternavn").val()=='')
	{
			 jQuery("#efternavn").attr('style','border:1px solid red');
			 temp=1;
	}
	else
		jQuery("#efternavn").attr('style','solid 1px #C5C5C5');


	if(jQuery("#alder").val()=='')
	{
			 jQuery("#alder").attr('style','border:1px solid red');
			 temp=1;
	}
	else
		jQuery("#alder").attr('style','solid 1px #C5C5C5');


	if(jQuery("#hojde").val()=='')
	{
			 jQuery("#hojde").attr('style','border:1px solid red');
			 temp=1;
	}
	else
		jQuery("#hojde").attr('style','solid 1px #C5C5C5');


	if(jQuery("#vagt").val()=='')
	{
			 jQuery("#vagt").attr('style','border:1px solid red');
			 temp=1;
	}
	else
		jQuery("#vagt").attr('style','solid 1px #C5C5C5');


	if(jQuery("#mobile").val()=='')
	{
			 jQuery("#mobile").attr('style','border:1px solid red');
			 temp=1;
	}
	else
		jQuery("#mobile").attr('style','solid 1px #C5C5C5');

/*
	if(jQuery("#sky").val()=='')
	{
			 jQuery("#sky").attr('style','border:1px solid red');
			 temp=1;
	}
	else
		jQuery("#sky").attr('style','solid 1px #C5C5C5');
*/

	if(!isValidEmail(jQuery("#email").val()))
	{
			 jQuery("#email").attr('style','border:1px solid red');
			 temp=1;
	}
	else
		jQuery("#email").attr('style','solid 1px #C5C5C5');

	if(temp==0)
		jQuery('#member-edit').submit();
}

</script>
<div class="wrapper">
	<div class="content" id="createAccount-page">
		<div class="col-wrapper clearfix">
			<div class="info">
				<ul class="breadcrumb mb20">
					<li class="active"><a>Personlige oplysninger</a></li>
					<li><a href="<?php echo JURI::root()?>index.php?option=com_users&view=profile&layout=edit2">Kostvaner/ønsker</a></li>
					<li><a href="<?php echo JURI::root()?>index.php?option=com_users&view=profile&layout=edit3">Motionsvaner/ønsker</a></li>
				</ul>
				<form id="member-edit" action="" method="post" class="form-validate">
					<h1 class="hd">Personlige oplysninger</h1>
					<div class="info-l mh460 bor">
						<div>
							<p>Alle felter markeret med *rød stjerne skal besvares – resten er valgfrie. Men vi opfordrer til at udfylde flest mulige felter, da det giver vejlederen mest mulig information inden jeres webmøde.</p><p>
Har du nogle spørgsmål eller andet undervejs, er du meget velkommen til at kontakt kundeservice <a href="index.php?option=com_contact&view=contact&id=1" style="text-decoration: underline" target="_blank">her</a></p>
						</div>
						<div>
							<label>Fornavn <span>*</span></label>
							<input name="jform[fornavn]" id="fornave" value="<?php echo str_replace(" ".$this->data->Efternavn,"",$this->data->name)?>">
						</div>
						<div class="ml15">
							<label>Efternavn <span>*</span></label>
							<input name="jform[efternavn]" id="efternavn" value="<?php echo $this->data->Efternavn;?>">
						</div>
						<div>
							<label class="mt17">Alder <span>*</span></label>
							<input class="w77" name="jform[Alder]" id="alder" value="<?php echo $this->data->Alder;?>">
						</div>
						<div class="ml10">
							<label class="mt17">Højde <span>*</span></label>
							<input class="w77" name="jform[Højde]" id="hojde" value="<?php echo $this->data->Højde;?>">
						</div>
						<div class="ml10">
							<label class="mt17">Vægt <span>*</span></label>
							<input class="w77" name="jform[Vægt]" id="vagt" value="<?php echo $this->data->Vægt;?>">
						</div>
						<div class="ml15">
							<label class="w126">Ønsker du vægttab<br>eller muskelforøgelse?</label>
							<select class="w138" name="jform[weekdown]" id="mangeuger">
								<option value="1" <?php if($weekdown==1) echo "selected"?>>Vægttab</option>
								<option value="2" <?php if($weekdown==2) echo "selected"?>>Muskelforøgelse</option>
								
							</select>
						</div>
						<div class="ml10">
							<label class="mt17">Hvor mange kg.?</label>
							<input class="w126" name="jform[weightdown]" id="duattabe" value="<?php echo $weightdown?>">
						</div>
						<div>
							<label>Mobiltelefon <span>*</span></label>
							<input name="jform[Mobiltelefon]" id="mobile" value="<?php echo $this->data->Mobiltelefon;?>">
						</div>
						<div class="ml15">
							<div class="w275 fl mb0">
							<label class="fl">Skype id</label>
							<div class="fl skypeid"><img src="<?php echo $tpath; ?>/img/imgInfo.png" alt="">
								<span class="tip">Skype bruges til de webmøder der afholdes mellem dig og din nye kost-/
								træningsvejleder.<br><br>
								Hvis du ikke har en Skype konto i forvejen, bedes du oprette en <a target="blank" href="https://login.skype.com/account/signup-form?return_url=https%3A%2F%2Fsecure.skype.com%2Faccount%2Flogin">her</a><br><br>
								Skype kan også bruges via din smartphone -hent Skype app'en <a target="blank" href="https://itunes.apple.com/en/app/skype-for-iphone/id304878510?mt=8">her</a><br><br>
								Har du problemer, så kontakt venligst vores support team <a target="blank" href="index.php?option=com_contact&view=contact&id=1">her</a>
								<span class="arr-left"></span></span>
							</div>
							</div>
							<div class="clear mb0"></div>
							<div class="fl">
							<input name="jform[skype]" id="sky" value="<?php echo $this->data->skype;?>" >
							</div>
						</div>
						<div>
							<label>E-mail <span>*</span></label>
							<input name="jform[email]" id="email" value="<?php echo $this->data->email;?>">
						</div>
					</div>

					<div class="info-r mh460 bor infor-nam">
						<div>
							<label>Din civilstatus:</label>
							<input <?php if($civilstatus=="") echo "checked" ?> class="ra" type="radio" name="jform[civilstatus]" value=""> Single<br class="mb5 mt10">
							<input <?php if($civilstatus !="") echo "checked" ?> class="ra" type="radio" name="jform[civilstatus]" value="1"> Samlevende?
						</div>
						<div>
							<label>Har du hjemmeboende børn?</label>
						</div>
						<div>
							<label class="fl">Hvis ja, hvor mange og<br>hvillken alder?</label>
							<?php
							$choicemaker=explode(',', $choicemaker);
							$choicecount=count($choicemaker);
							?>
							<select class="w115 ml15" id="choicemaker" name="jform[choicemaker]">
								<option value="">Nej</option>
								<option value="1" <?php if($choicecount==1) echo "selected"?>>1</option>
								<option value="2" <?php if($choicecount==2) echo "selected"?>>2</option>
								<option value="3" <?php if($choicecount==3) echo "selected"?>>3</option>
								<option value="4" <?php if($choicecount==4) echo "selected"?>>4</option>
							</select>
						</div>
						<div id="w-privat">
							<div id="nam1" <?php if($choicecount==0) echo 'class="hide"'?>>
								<label>Alder på 1. barn (år)</label>
								<input class="w111" name="jform[kidage][0]" id="text_nam_1" value="<?php echo $choicemaker[0]?>">
							</div>
							 <div class="ml10<?php if($choicecount<2) echo ' hide'?>" id="nam2">
								<label>Alder på 2. barn (år)</label>
								<input class="w111" name="jform[kidage][1]" id="text_nam_2" value="<?php echo $choicemaker[1]?>">
							</div>
							 <div id="nam3" <?php if($choicecount<3) echo 'class="hide"'?>>
								<label>Alder på 3. barn (år)</label>
								<input class="w111" name="jform[kidage][2]" id="text_nam_3" value="<?php echo $choicemaker[2]?>">
							</div>
							 <div class="ml10<?php if($choicecount<4) echo ' hide'?>" id="nam4">
								<label>Alder på 4. barn (år)</label>
								<input class="w111" name="jform[kidage][3]" id="text_nam_4" value="<?php echo $choicemaker[3]?>">
							</div>
						</div>
						<div>
							<label>Delmål:</label>
							<p class="mt10">Hvor mange kg. ønsker du at tabe?</p>
						</div>
						<?php 
							$hvorkg=explode(',',$hvorkg);
							?>
						<div>
							<label>1. måned (Kg)</label>
							<input class="w111" name="jform[hvorkg][0]" id="hvorkg1" value="<?php echo $hvorkg[0]?>">
						</div>
						 <div class="ml10">
							<label>2. måned (Kg)</label>
							<input class="w111" name="jform[hvorkg][1]" id="hvorkg2" value="<?php echo $hvorkg[1]?>">
						</div>
						 <div>
							<label>3. måned (Kg)</label>
							<input class="w111" name="jform[hvorkg][2]" id="hvorkg3" value="<?php echo $hvorkg[2]?>">
						</div>
						 <div class="ml10">
							<label>4. måned (Kg)</label>
							<input class="w111" name="jform[hvorkg][3]" id="hvorkg4" value="<?php echo $hvorkg[3]?>">
						</div>
					</div>
					<div class="clear"></div>
					<a class="fr bntNext" onclick="check()">Næste</a>
					<input type="hidden" name="option" value="com_users" />
					<input type="hidden" name="task" value="profile.edit" />
					<input type="hidden" name="user_id" value=<?php echo $user->id?> />
					<?php echo JHtml::_('form.token');?>
				</form>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	alertmsg=$('.message').last().text();
	if(alertmsg)
		alert(alertmsg);
</script>